﻿using System.Collections.Generic;
using System.Linq;
using FoodRaidersWebAPI.domainnew.other;
using FoodRaidersWebAPI.Models;

namespace FoodRaidersWebAPI.Service.Third
{
    public class PictureService
    {
        private readonly FoodContext context;

        public PictureService(FoodContext context)
        {
            this.context = context;
        }
        //id查询 对象不加载
        public Picture findByID(int id)
        {
            return context.Pictures.FirstOrDefault(p => p.PictureID == id);
        }
        //返回指定aid的文章的所有图片id 按获赞数降序排列
        public List<int> findAllID(int aid)
        {
            var query = context.Pictures.Where(a => a.ArticleID == aid).Select(a => a.PictureID);
            return query.ToList();
        }
    }
}